<template>
  <div class="ChildPage TablePage">
    <vb-table :option="option" ref="table"
               @row-del="rowDel"
               @row-update="rowUpdate"
               @row-save="rowSave"
               @on-load="getList">
    </vb-table>
    <PowerDialog ref="powerDialog"></PowerDialog>
  </div>
</template>

<script>
import PowerDialog from "../components/dialog/PowerDialog.vue"

export default {
  mixins: [],
  components: {
    PowerDialog
  },
  data() {
    return {
      option: {
        selection: true,
        index: true,
        column: [
          {
            label: "参数名称",
            prop: "name",
            search: {
              show: true,
              label: "关键词",
              prop: "keyword",
              hiddenLabel: true,
              placeholder: "\ue605 参数名称/键名/键值"
            },
            form: {
              span: 24,
              rules: [
                {
                  required: true,
                  message: "请输入角色名称",
                  trigger: "click"
                }
              ],
            },
          },
          {
            label: "参数键名",
            prop: 'key',
            form: {
              span: 24,
              rules: [
                {
                  required: true,
                  trigger: "click"
                }
              ],
            },
          },
          {
            label: "参数键值",
            prop: "val",
            align: "center",
            form: {
              span: 24,
              rules: [
                {
                  required: true,
                  trigger: "click"
                }
              ],
            },
          }
        ],
        form: {
          width: 400
        },
      }
    }
  },
  computed: {},
  async mounted() {
  },
  methods: {

    /**
     * 查询数据列表信息
     * @param page
     * @param size
     * @param search 检索条件
     * @param done
     */
    getList(page, size, search, done) {
      this.$api.getCharacterList(Object.assign({
        pageIndex: page,
        pageSize: size
      }, search)).then(res => {
        done(res)
      })
    },

    /**
     * 新增数据处理
     * @param form
     * @param done
     */
    rowSave(form, done) {
      this.$api.addCharacter(form).then((res) => {
        done(res)
      })
    },

    /**
     * 更新数据处理
     * @param form
     * @param done
     */
    rowUpdate(form, done) {
      this.$api.updateCharacter(form).then((res) => {
        done(res)
      })
    },

    /**
     * 删除数据处理
     * @param ids
     * @param done
     */
    rowDel(ids, done) {
      this.$api.deleteCharacter({
        ids: ids
      }).then((res) => {
        done(res)
      })
    },

    /**
     * 编辑权限
     * @param row
     */
    editPower(row) {
      this.$refs.powerDialog.open({
        id: row.id,
      })
    }
  },
  watch: {}
}
</script>

<style lang="scss" scoped>
</style>
